home *** CD-ROM | disk | FTP | other *** search
Wrap
import java.applet.Applet; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Event; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Image; import java.net.URL; import java.util.Date; import java.util.StringTokenizer; public class zticker extends Applet implements Runnable { // $FF: renamed from: im java.awt.Image public Image field_0; // $FF: renamed from: gr java.awt.Graphics public Graphics field_1; public String message; public Font messageF; public int messageX; public int messageY; public int messageW; public URL url_; int speed; // $FF: renamed from: t java.lang.Thread public Thread field_2; public Color txtCo; public int txtStyle; public Color shCo1; public Color shCo2; public Color hrefCo; public Color bgCo; public boolean ExFill; public boolean expired = false; public boolean useShadow; public boolean useFrame; public Dimension lastS = new Dimension(1, 1); public String fixedgetParameter(String var1) { char[] var2 = var1.toCharArray(); for(int var3 = 0; var3 < var2.length; ++var3) { var2[var3] = (char)(var2[var3] & 255); } return new String(var2); } public void init() { Date var1 = new Date(); String var3 = ((Applet)this).getParameter("msg"); this.message = var3 == null ? "zticker for beta" : this.fixedgetParameter(var3); this.bgCo = this.readColor(((Applet)this).getParameter("exp"), Color.white); if (!this.bgCo.equals(Color.white)) { Date var2 = new Date(this.bgCo.getRed(), this.bgCo.getGreen() - 1, this.bgCo.getBlue()); this.expired = var1.after(var2); } if (!this.expired) { this.bgCo = this.readColor(((Applet)this).getParameter("start"), Color.black); if (!this.bgCo.equals(Color.black)) { Date var8 = new Date(this.bgCo.getRed(), this.bgCo.getGreen() - 1, this.bgCo.getBlue()); this.expired = var8.after(var1); } } this.ExFill = ((Applet)this).getParameter("exfill") != null; if (this.expired && !this.ExFill) { ((Applet)this).resize(2, 2); } else { this.speed = (var3 = ((Applet)this).getParameter("speed")) == null ? 10 : Integer.valueOf(var3); if ((var3 = ((Applet)this).getParameter("href")) != null) { try { this.url_ = new URL(((Applet)this).getDocumentBase(), var3); } catch (Exception var7) { this.url_ = null; } } if (this.url_ == null) { this.bgCo = Color.black; } else { this.bgCo = Color.blue; } this.txtCo = this.readColor(((Applet)this).getParameter("txtco"), this.bgCo); this.bgCo = this.readColor(((Applet)this).getParameter("bgco"), ((Component)this).getBackground()); this.shCo2 = this.readColor(((Applet)this).getParameter("shco"), this.bgCo); this.useShadow = !this.shCo2.equals(this.bgCo); this.hrefCo = this.readColor(((Applet)this).getParameter("hrefco"), Color.blue); this.useFrame = !this.hrefCo.equals(this.bgCo); this.txtStyle = this.useShadow ? 0 : 1; if (this.useShadow) { int var4 = this.shCo2.getRed() + this.txtCo.getRed() >> 1; int var5 = this.shCo2.getGreen() + this.txtCo.getGreen() >> 1; int var6 = this.shCo2.getBlue() + this.txtCo.getBlue() >> 1; this.shCo1 = new Color(var4, var5, var6); } } } public String[][] getParameterInfo() { String[][] var1 = new String[][]{{"msg", "String", "Message to display"}, {"href", "String", "url to switch to"}, {"speed", "int", "animation speed in pixels (10)"}, {"txtco", "int[3]", "RGB-Color of Message (black/blue)"}, {"hrefco", "int[3]", "RGB-Color of Frame (blue)"}, {"bgco", "int[3]", "RGB-Color of background (getBackground)"}, {"shco", "int[3]", "RGB-Color of Message (black/blue)"}, {"start", "int[3]", "Date to start: Y, M, D; if not set, show"}, {"exp", "int[3]", "Date to expire: Y, M, D; if not set, no expiration"}, {"exfill", "", "If exist, fill with bgco, if expired"}}; return var1; } public String getAppletInfo() { return "zticker.java, V b1.30, 02/07/96 by Thomas Wendt, http://www.uni-kassel.de/fb16/ipm/mt/staff/thwendte.html"; } public Color readColor(String var1, Color var2) { if (var1 == null) { return var2; } else { StringTokenizer var6 = new StringTokenizer(var1, ","); try { int var3 = Integer.valueOf(var6.nextToken()); int var4 = Integer.valueOf(var6.nextToken()); int var5 = Integer.valueOf(var6.nextToken()); return new Color(var3, var4, var5); } catch (Exception var7) { return var2; } } } public void createParams() { int var1 = ((Component)this).size().width; int var2 = ((Component)this).size().height; this.lastS.width = var1; this.lastS.height = var2; byte var3 = 14; Font var4 = new Font("TimesRoman", this.txtStyle, var3); ((Component)this).setFont(var4); FontMetrics var5 = ((Component)this).getFontMetrics(var4); int var6 = var5.getHeight(); var6 = var3 * (var2 - 10) / var6; this.messageF = new Font("TimesRoman", this.txtStyle, var6); FontMetrics var7 = ((Component)this).getFontMetrics(this.messageF); var6 = var7.getHeight(); this.messageX = var1; this.messageY = (var2 - var6 >> 1) + var7.getAscent(); this.messageW = var7.stringWidth(this.message); if (this.field_1 != null) { this.field_1.dispose(); } this.field_0 = ((Component)this).createImage(this.lastS.width, this.lastS.height); this.field_1 = this.field_0.getGraphics(); } public void paint(Graphics var1) { this.update(var1); } public synchronized void update(Graphics var1) { int var2 = ((Component)this).size().width; int var3 = ((Component)this).size().height; if (this.expired) { if (this.ExFill) { var1.setColor(this.bgCo); var1.fillRect(0, 0, var2, var3); } } else { if (var3 != this.lastS.height || var2 != this.lastS.width) { this.createParams(); } this.field_1.setColor(this.bgCo); this.field_1.fillRect(0, 0, var2, var3); if (this.url_ != null && this.useFrame) { this.field_1.setColor(this.hrefCo); this.field_1.clipRect(0, 0, var2, var3); this.field_1.drawRect(0, 0, var2, var3); this.field_1.drawRect(1, 1, var2 - 2, var3 - 2); this.field_1.setColor(this.bgCo); this.field_1.draw3DRect(2, 2, var2 - 4, var3 - 4, true); this.field_1.draw3DRect(3, 3, var2 - 6, var3 - 6, true); this.field_1.clipRect(4, 4, var2 - 8, var3 - 8); } this.field_1.setFont(this.messageF); if (this.useShadow) { this.field_1.setColor(this.shCo2); this.field_1.drawString(this.message, this.messageX + 2, this.messageY + 1); this.field_1.setColor(this.shCo1); this.field_1.drawString(this.message, this.messageX + 1, this.messageY); } this.field_1.setColor(this.txtCo); this.field_1.drawString(this.message, this.messageX, this.messageY); var1.drawImage(this.field_0, 0, 0, this); } } public void calcPos() { this.messageX -= this.speed; if (this.messageX + this.messageW < 0) { this.messageX = ((Component)this).size().width; } } public void run() { if (!this.expired) { Thread.currentThread().setPriority(1); while(this.field_2 != null) { ((Component)this).repaint(); this.calcPos(); try { Thread.sleep(100L); } catch (InterruptedException var1) { } } } } public void start() { if (this.field_2 == null) { this.field_2 = new Thread(this); this.field_2.start(); } } public void stop() { if (this.field_2 != null) { this.field_2.stop(); this.field_2 = null; } this.field_0 = null; if (this.field_1 != null) { this.field_1.dispose(); this.field_1 = null; } this.lastS = new Dimension(1, 1); } public boolean mouseUp(Event var1, int var2, int var3) { if (this.url_ != null) { ((Applet)this).getAppletContext().showDocument(this.url_); } return true; } public boolean mouseEnter(Event var1, int var2, int var3) { if (this.url_ != null) { ((Applet)this).showStatus(this.url_.toExternalForm()); } return true; } public boolean mouseExit(Event var1, int var2, int var3) { if (this.url_ != null) { ((Applet)this).showStatus(" "); } return true; } }